cmake_minimum_required(VERSION 3.25)

project(ddoffice_im)

#设置编译器编译模式：
set( CMAKE_BUILD_TYPE "Debug" )
# 设置使用的C++版本
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_C_STANDARD 20)

# 定义变量
set(LIBHV_INCLUDE /usr/local/include)
set(LIBHV_LIBRARIES /usr/local/lib)
set(LIBOPENSSL_LIB /usr/local/Cellar/openssl@3/3.2.0_1/lib)
set(LIBOPENSSL_INCLUDE /usr/local/Cellar/openssl@3/3.2.0_1/include)

#FIND_PACKAGE(OpenSSL)
#if(${OpenSSL_FOUND})
#    INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
#endif()

# 链接外部库
include_directories(${LIBHV_INCLUDE})
link_directories(${LIBHV_LIBRARIES})

include_directories(${LIBOPENSSL_INCLUDE})
link_directories(${LIBOPENSSL_LIB})

# 打印信息 方便调试编译脚本
#message("LIBHV_INCLUDE=${LIBHV_INCLUDE}")
#message("LIBHV_LIBRARIES=${LIBHV_LIBRARIES}")
message("PROJECT_NAME=${PROJECT_NAME}")
#message("PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}")
#message("OPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}")
#message("OPENSSL_LIBRARIES_DIR=${OPENSSL_LIBRARIES_DIR}")
#file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "src/*.cpp")

#将所有的源文件列为一个集合，集合名字叫做 SRC_FILES
aux_source_directory("${PROJECT_SOURCE_DIR}" SRC_FILES)
#搜索 utils 子目录源代码文件(名), 记在 UTILS_SRC 变量
aux_source_directory(../utils UTILS_SRC)
#搜索 sql 子目录源代码文件(名), 记在 SQL_SRC 变量
aux_source_directory(../sql SQL_SRC)
#搜索 sql/tabs 子目录源代码文件(名), 记在 SQL_TABS_SRC 变量
aux_source_directory(../sql/tabs SQL_TABS_SRC)
# 打印路径 排查是否正确
message(${SRC_FILES})
message(${UTILS_SRC})
message(${SQL_SRC})
message(${SQL_TABS_SRC})
add_executable(ddoffice_im ${SRC_FILES} ${UTILS_SRC} ${SQL_SRC} ${SQL_TABS_SRC})
# 指定链接那个库
target_link_libraries (${PROJECT_NAME} libhv.a)
target_link_libraries (${PROJECT_NAME} libmysqlclient.a)
target_link_libraries (${PROJECT_NAME} libhiredis.a)
target_link_libraries (${PROJECT_NAME} libssl.a)
target_link_libraries (${PROJECT_NAME} libcrypto.a)
#target_link_libraries (${PROJECT_NAME} ssl crypto)
